package com.wryyyyy.service.impl;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;

import static com.wryyyyy.utils.SystemConstants.PROCESS_ABSOLUTE_PATH;

@Service
public class CallService {
    @Resource
    private CppProgramExecutor cppProgramExecutor;

    public String[] executeCppProgram(Integer method, String[] args) {
        String process = "";
        switch (method) {
            case 1 :
                process = "dengshi.exe";
                break;
            case 2 :
                process = "huidu.exe";
                break;
            case 3 :
                process = "three.exe";
                break;
            default :
                break;
        }
        // 假设C++可执行文件位于项目的根目录下
        String programPath = PROCESS_ABSOLUTE_PATH + process;
        // 如果有额外的命令行参数，可以传递它们作为数组
//        String[] arguments = {"arg1", "arg2"};
        // 执行C++程序并获取输出
        // 返回输出或进行其他处理
        return cppProgramExecutor.executeCppProgram(programPath, args);
    }
}